package com.ndf.learn.verify.captcha;

import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Explain:随机数工具类
 */
public class Randoms
{
    private static final Random RANDOM = new Random();
    /**
     * 产生两个数之间的随机数
     * @param min 小数
     * @param max 比min大的数
     * @return int 随机数字
     */
    public static int num(int min, int max)
    {
        return min + RANDOM.nextInt(max - min);
    }

    /**
     * 产生0--num的随机数,不包括num
     * @param num 数字
     * @return int 随机数字
     */
    public static int num(int num)
    {
        return RANDOM.nextInt(num);
    }

    public static void main(String[] args) {
        String userName = "12345678aZ]";

        boolean wb  = Pattern.matches("^.*[a-zA-Z]+.*$", userName);
        System.out.println(wb);

        boolean ib = Pattern.matches("^.*[0-9]+.*$", userName);
        System.out.println(ib);

        boolean sb = Pattern.matches("^.*[`~!@#$%^&*()_+\\-=<>?:{},./;'|(\\[)(\\])]+.*$", userName);
        System.out.println(sb);
    }

}